<template>
  <div class="brand-wrapper">
    <!--    搜索区域-->
    <div class="search-box">
      <el-form :inline="true" class="demo-form-inline" size="mini">
        <el-form-item label="员工姓名">
          <el-input v-model="searchForm.adminName" placeholder="请输入员工姓名"></el-input>
        </el-form-item>
        <el-form-item label="员工手机">
          <el-input v-model="searchForm.adminPhone" placeholder="请输入手机号"></el-input>
        </el-form-item>

        <el-form-item label="员工性别">
          <el-select v-model="searchForm.gender" placeholder="请选择性别">
            <el-option label="男" value="0"/>
            <el-option label="女" value="1"/>
            <el-option label="人妖" value="2"/>
          </el-select>
          <!--          <el-input v-model="searchForm.adminPhone" placeholder="请输入手机号"></el-input>-->
        </el-form-item>
        <el-date-picker
            v-model="chooseDate"
            style="width: 280px"
            type="datetimerange"
            :picker-options="pickerOptions"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd HH:mm:ss"
            @change="chooseDateChange"
            size="mini"
            align="right">
        </el-date-picker>
        <el-form-item style="margin-left: 10px">
          <el-button type="primary" @click="searchPage">搜索</el-button>
          <el-button type="warning" @click="resetSearchForm">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!--    操作区域  -->
    <div class="exec-box">
      <el-button type="primary" size="mini" @click="addBtnClick" v-hasperm="'system:admin:add'">新建</el-button>
      <el-button type="success" size="mini" :disabled="selectIds.length!=1"
               v-hasperm="'system:admin:edit'"  @click="createDialog=true,findById(selectIds[0])">编辑
      </el-button>
      <a class="el-button el-button--warning el-button--mini"  style="text-decoration: none"  v-hasperm="'system:admin:export'" href="http://localhost:10086/admin/exportExcel" >导出</a>
      <el-button type="danger" size="mini" :disabled="selectIds.length<=0" @click="showBatchDeleteDialog" v-hasperm="'system:admin:batch'">删除</el-button>
    </div>
    <!--    数据表格-->
    <el-scrollbar>
      <el-table
          @selection-change="selectChange"
          :data="tableData"
          style="width: 100%">
        <el-table-column type="expand">
          <template slot-scope="props">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-form-item label="员工id">
                <span>{{ props.row.id }}</span>
              </el-form-item>
              <el-form-item label="员工账户">
                <span>{{ props.row.adminAccount }}</span>
              </el-form-item>
              <el-form-item label="员工名称">
                <span>{{ props.row.adminName }}</span>
              </el-form-item>
              <el-form-item label="员工性别">
                <el-tag v-if="props.row.gender==0">男</el-tag>
                <el-tag v-if="props.row.gender==1" type="success">女</el-tag>
                <el-tag v-if="props.row.gender==2" type="danger">人妖</el-tag>
              </el-form-item>
              <el-form-item label="员工手机">
                <span>{{ props.row.adminPhone }}</span>
              </el-form-item>
              <el-form-item label="员工头像">
                <img :src="props.row.adminAvatar" width="35" height="35px" style="border-radius: 50%"/>
              </el-form-item>
              <el-form-item label="员工邮箱">
                <span>{{ props.row.adminEmail }}</span>
              </el-form-item>
              <el-form-item label="是否激活">
                <el-switch
                    v-model="props.row.isActive "
                    active-color="#13ce66"
                    inactive-color="#ff4949"
                    disabled>
                </el-switch>

              </el-form-item>
              <el-form-item label="身份号码">
                <span>{{ props.row.adminCode }}</span>
              </el-form-item>
              <el-form-item label="是否超管">
                <el-switch
                    v-model="props.row.isAdmin"
                    active-color="#13ce66"
                    inactive-color="#ff4949"
                    disabled>
                </el-switch>
              </el-form-item>

              <el-form-item label="员工薪资">
                <span>{{ props.row.adminSalary }}</span>
              </el-form-item>
              <el-form-item label="员工地地">
                <span>{{ props.row.adminAddress }}</span>
              </el-form-item>

            </el-form>
          </template>
        </el-table-column>
        <el-table-column
            type="selection"
            align="center"
            width="55"/>
        <el-table-column
            align="center"
            prop="id"
            label="员工ID"
            width="80"
        >
        </el-table-column>

        <el-table-column
            align="center"
            prop="adminName"
            label="员工姓名"
        >
        </el-table-column>
        <el-table-column
            align="center"
            prop="adminPhone"
            label="员工手机"
        >
        </el-table-column>
        <el-table-column
            align="center"
            label="员工头像">
          <template v-slot="obj">
            <img :src="obj.row.adminAvatar" width="35" height="35px" style="border-radius: 50%"/>
          </template>
        </el-table-column>
        <el-table-column
            align="center"
            prop="isActive"
            label="是否可用"
        >
          <template v-slot="obj">
            <el-switch
                v-model="obj.row.isAdmin"
                active-color="#13ce66"
                inactive-color="#ff4949"
                disabled>
            </el-switch>
          </template>
        </el-table-column>

        <el-table-column
            align="center"
            prop="adminSalary"
            label="员工薪资"
        >
        </el-table-column>


        <el-table-column
            align="center"
            label="操作"
        >
          <template v-slot="obj">
            <el-button type="success" size="mini" @click="findById(obj.row.id)" v-hasperm="'system:admin:edit'">编辑</el-button>
            <el-popconfirm
                style="margin-left: 8px"
                confirm-button-text='好的'
                cancel-button-text='不用了'
                icon="el-icon-info"
                @confirm="deleteById(obj.row.id)"
                icon-color="red"
                title="这是一段内容确定删除吗？"
            >
              <el-button slot="reference" size="mini" type="danger" v-hasperm="'system:admin:delete'">删除</el-button>
            </el-popconfirm>

          </template>

        </el-table-column>

      </el-table>

      <!--    分页区域 -->
      <div class="page-box">
        <el-pagination
            background
            layout="prev, pager, next"
            @current-change="pageChange"
            :page-size="searchForm.pageSize"
            :current-page="searchForm.currentPage"
            :total="total">
        </el-pagination>
      </div>
    </el-scrollbar>

    <!--    新建弹框-->
    <el-dialog
        title="实体操作"
        :visible.sync="createDialog"
        width="40%">
      <el-form ref="form" label-width="80px" :model="formData" :rules="rules" label-position="middle" size="mini">

        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="员工账户" prop="adminAccount">
              <el-input v-model="formData.adminAccount"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="员工姓名" prop="adminName">
              <el-input v-model="formData.adminName"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="员工性别" prop="gender">
              <el-radio-group v-model="formData.gender">
                <el-radio :label="0">男</el-radio>
                <el-radio :label="1">女</el-radio>
                <el-radio :label="2">人妖</el-radio>
              </el-radio-group>

            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="员工手机" prop="adminPhone">
              <el-input v-model="formData.adminPhone"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="员工邮箱" prop="adminEmail">
              <el-input v-model="formData.adminEmail"></el-input>
            </el-form-item>

          </el-col>
          <el-col :span="12">
            <el-form-item label="是否激活">
              <el-switch
                  v-model="formData.isActive"
                  active-color="#13ce66"
                  inactive-color="#ff4949">
              </el-switch>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="身份证号" prop="adminCode">
              <el-input v-model="formData.adminCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="员工薪资" prop="adminSalary">
              <el-input v-model="formData.adminSalary"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="员工头像">
              <!--          <el-input v-model="formData.brandLogo"></el-input>-->
              <el-upload
                  class="avatar-uploader"
                  action="https://jsonplaceholder.typicode.com/posts/"
                  :http-request="chooseImg"
                  :before-upload="beforeAvatarUpload"
                  :show-file-list="false">
                <img v-if="imgUrl" :src="imgUrl" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="分配角色" >
              <el-select v-model="formData.roleIds" multiple placeholder="请选项角色">
                <el-option
                    v-for="role in roleList"
                    :key="role.id"
                    :label="role.roleName"
                    :value="role.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="员工地址" prop="adminAddress">
          <el-input type="textarea" v-model="formData.adminAddress"></el-input>
        </el-form-item>

      </el-form>
      <span slot="footer" class="dialog-footer">
    <el-button @click="createDialog = false" size="mini">取 消</el-button>
    <el-button type="success" @click="addOrEdit" size="mini">确 定</el-button>
  </span>
    </el-dialog>
  </div>

</template>

<script src="./index.js"></script>

<style src="./index.scss" lang="scss">

</style>
